home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / pars.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-30  |  10.6 KB  |  375 lines

  1. /*
  2.     GWAda Development Environment for 386/486 PCs   
  3.     Copyright (C) 1993, Arthur Vargas Lopes  & Michael Bliss Feldman
  4.                         vlopes@vortex.ufrgs.br mfeldman@seas.gwu.edu
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; version 2 of the License.    
  9.  
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. /*  Pars.c  */
  22.  
  23. #include <externs.h>
  24.  
  25. static avl_cur_par = 0;
  26.  
  27.  
  28. void AVL_SET_MONITOR() 
  29. {
  30.     AVL_WIN_PTR hw, hw2;
  31.     short h, co;
  32.     char opts[6];
  33.     char msg[80];
  34.     int ch;
  35.     char old;
  36.     old = avl_monitor_on;
  37.     hw2 = AVL_MAKE_WINDOW("",18,7,21,77,avl_wnd_bk_color,avl_wnd_color);
  38.     _outtext(" Set the Parallel Monitoring On/Off:\n");
  39.     _outtext(" ESC-Cancel  ENTER-Ok  Type the digit to set/reset the option.");
  40.     _settextposition(2,2); 
  41.     co = _settextcolor(avl_men_ready);
  42.     _outtext("ESC");
  43.     _settextposition(2,14); 
  44.     _outtext("ENTER");
  45.     _settextcolor(co);
  46.     hw = AVL_MAKE_WINDOW(" Monitoring ",5,2,7,79,avl_wnd_bk_color,avl_wnd_color);
  47.     _outtext(" 1. Off  Source line monitoring");
  48.     _settextcursor(0x2000);
  49.     while ( 1 )   {
  50.         _settextposition(1,5); 
  51.         if (avl_monitor_on) {
  52.             _settextcolor(avl_men_ready);
  53.             _outtext("On "); 
  54.             }
  55.         else  { 
  56.             _settextcolor(avl_men_letter);
  57.             _outtext("Off");
  58.             }
  59.         ch = getch();
  60.         if (ch == '1')   {
  61.             h = ch - '1';
  62.             avl_monitor_on = !avl_monitor_on;
  63.             }
  64.         else if (ch == 27) {avl_monitor_on = old; break; }
  65.         else if (ch == 13)  
  66.             break;
  67.         else if (ch == 0) ch = getch();
  68.         }
  69.     AVL_DEL_WINDOW(hw);
  70.     AVL_DEL_WINDOW(hw2);
  71.         
  72. }
  73.  
  74.  
  75. void AVL_SET_TRACE() 
  76. {
  77.     AVL_WIN_PTR hw, hw2;
  78.     short h, co;
  79.     char opts[6];
  80.     char msg[80];
  81.     int ch;
  82.     hw2 = AVL_MAKE_WINDOW("",18,9,21,78,avl_wnd_bk_color,avl_wnd_color);
  83.     _outtext(" Specify the kind of trace requested for the program's execution:\n");
  84.     _outtext(" ESC-Cancel    ENTER-Ok    Type the digit to set/reset an option.");
  85.     _settextposition(2,2); 
  86.     co = _settextcolor(avl_men_ready);
  87.     _outtext("ESC");
  88.     _settextposition(2,16); 
  89.     _outtext("ENTER");
  90.     _settextcolor(co);
  91.     hw = AVL_MAKE_WINDOW(" Trace ",5,2,13,79,avl_wnd_bk_color,avl_wnd_color);
  92.     _outtext(" 1. Off  Display the source line numbers.\n");
  93.     _outtext("         There is no need to recompile the program.\n");
  94.     _outtext(" 2. Off  Display the name of each routine as it is entered and exited.\n");
  95.     _outtext(" 3. Off  Display the name of each exception as it is raised.\n");
  96.     _outtext(" 4. Off  Trace each rendezvous.\n");
  97.     _outtext(" 5. Off  Display the context-switches between tasks.\n");
  98.     _outtext(" 6. Off  Display task creation, activation, and termination.");
  99.     for(h = 0; h < 6; ++h)
  100.         opts[h] = avl_trace_opts[h];
  101.     _settextcursor(0x2000);
  102.     while ( 1 )   {
  103.         _settextposition(1,5); 
  104.         if (opts[0]) {
  105.             _settextcolor(avl_men_ready);
  106.             _outtext("On "); 
  107.             }
  108.         else  { 
  109.             _settextcolor(avl_men_letter);
  110.             _outtext("Off");
  111.             }
  112.         _settextposition(3,5); 
  113.         if (opts[1]) {
  114.             _settextcolor(avl_men_ready);
  115.             _outtext("On "); 
  116.             }
  117.         else  { 
  118.             _settextcolor(avl_men_letter);
  119.             _outtext("Off");
  120.             }
  121.         _settextposition(4,5); 
  122.         if (opts[2]) {
  123.             _settextcolor(avl_men_ready);
  124.             _outtext("On "); 
  125.             }
  126.         else  { 
  127.             _settextcolor(avl_men_letter);
  128.             _outtext("Off");
  129.             }
  130.         _settextposition(5,5); 
  131.         if (opts[3]) {
  132.             _settextcolor(avl_men_ready);
  133.             _outtext("On "); 
  134.             }
  135.         else  { 
  136.             _settextcolor(avl_men_letter);
  137.             _outtext("Off");
  138.             }
  139.         _settextposition(6,5); 
  140.         if (opts[4]) {
  141.             _settextcolor(avl_men_ready);
  142.             _outtext("On "); 
  143.             }
  144.         else  { 
  145.             _settextcolor(avl_men_letter);
  146.             _outtext("Off");
  147.             }
  148.         _settextposition(7,5); 
  149.         if (opts[5]) {
  150.             _settextcolor(avl_men_ready);
  151.             _outtext("On "); 
  152.             }
  153.         else  { 
  154.             _settextcolor(avl_men_letter);
  155.             _outtext("Off");
  156.             }
  157.         ch = getch();
  158.         if (ch >= '1' && ch <= '6')   {
  159.             h = ch - '1';
  160.             opts[h] = !opts[h];
  161.             }
  162.         else if (ch == 27) break;
  163.         else if (ch == 13)  {
  164.             for(h = 0; h < 6; ++h)
  165.                 avl_trace_opts[h] = opts[h];
  166.             break;
  167.             }
  168.         }
  169.     AVL_DEL_WINDOW(hw);
  170.     AVL_DEL_WINDOW(hw2);
  171.         
  172. /* -t [acerst]  */
  173. }
  174.  
  175. void AVL_SET_SCHEDULER() 
  176. {
  177.     AVL_WIN_PTR hw, hw2;
  178.     short h;
  179.     char msg[80];
  180.     hw2 = AVL_MAKE_WINDOW("",18,3,24,77,avl_wnd_bk_color,avl_wnd_color);
  181.     _outtext(" Invoke a 'round-robin' scheduling policy instead of the 'run-until-\n");
  182.     _outtext(" -block' default scheduling policy and specify the maximum number of\n");
  183.     _outtext(" interpreted statements that a given task can execute before switching\n");
  184.     _outtext(" to another task. (the minimum value is 1).\n");
  185.     _outtext(" A value 0 sets the 'run-until-block' schedulling policy.");
  186.     hw = AVL_MAKE_WINDOW(" Scheduller ",13,20,13+2
  187.                                          ,63,avl_wnd_bk_color,avl_wnd_color);
  188.     while ( 1 )   {
  189.         sprintf(msg,"%d", avl_scheduller);
  190.         if (AVL_PROMPT(1,3,msg,3)) break;
  191.         if (strlen(msg) > 0) {
  192.             h = atoi(msg);
  193.             if (h < 0) AVL_ERROR("Invalid number of interpreted statements."); 
  194.             else {
  195.                 avl_scheduller = h;
  196.                 break;
  197.                 }
  198.             }
  199.         }
  200.     AVL_DEL_WINDOW(hw);
  201.     AVL_DEL_WINDOW(hw2);
  202.         
  203. /* -r number_of_statements (an integer)*/
  204. }
  205.  
  206.  
  207. void AVL_SET_TASK_STACK() 
  208. {
  209.     AVL_WIN_PTR hw, hw2;
  210.     short h;
  211.     char msg[80];
  212.     hw2 = AVL_MAKE_WINDOW("",18,3,24,76,avl_wnd_bk_color,avl_wnd_color);
  213.     _outtext(" Specifies the size in bytes of the stack size for each new task.\n");
  214.     _outtext(" The default is 2048. Argument values in the range 1..31 are multiplied\n");
  215.     _outtext(" by 1024 to obtain the stack size in bytes. Use of small stack sizes\n");
  216.     _outtext(" may be appropriate when executing programs with many tasks, each of\n");
  217.     _outtext(" which can run with a small stack.  The maximum value is 32767.");
  218.     hw = AVL_MAKE_WINDOW(" Task Stack ",13,20,13+2
  219.                                          ,63,avl_wnd_bk_color,avl_wnd_color);
  220.     while ( 1 )   {
  221.         sprintf(msg,"%d", avl_task_stack);
  222.         if (AVL_PROMPT(1,3,msg,3)) break;
  223.         if (strlen(msg) > 0) {
  224.             h = atoi(msg);
  225.             if (h <= 0) AVL_ERROR("Invalid task stack."); 
  226.             else {
  227.                 avl_task_stack = h;
  228.                 break;
  229.                 }
  230.             }
  231.         }
  232.     AVL_DEL_WINDOW(hw);
  233.     AVL_DEL_WINDOW(hw2);
  234.         
  235. /*  -s tstack  */
  236. }
  237.  
  238.  
  239. void AVL_SET_HEAP_SIZE()
  240. {
  241.     AVL_WIN_PTR hw, hw2;
  242.     short h;
  243.     char msg[80];
  244.     hw2 = AVL_MAKE_WINDOW("",18,4,24,75,avl_wnd_bk_color,avl_wnd_color);
  245.     _outtext(" Specifies the size of the heap increment in kilowords, by which the\n");
  246.     _outtext(" heap is expanded when the elaboration of a new entity requires it.\n");
  247.     _outtext(" The heap expands to fill available memory. The default increment is\n");
  248.     _outtext(" 32. This parameter limits the size of the largest object that can be\n");
  249.     _outtext(" created in a program.");
  250.     hw = AVL_MAKE_WINDOW(" Heap Size ",13,20,13+2
  251.                                          ,63,avl_wnd_bk_color,avl_wnd_color);
  252.     while ( 1 )   {
  253.         sprintf(msg,"%d", avl_heap);
  254.         if (AVL_PROMPT(1,3,msg,3)) break;
  255.         if (strlen(msg) > 0) {
  256.             h = atoi(msg);
  257.             if (h <= 0) AVL_ERROR("Invalid heap size."); 
  258.             else {
  259.                 avl_heap = h;
  260.                 break;
  261.                 }
  262.             }
  263.         }
  264.     AVL_DEL_WINDOW(hw);
  265.     AVL_DEL_WINDOW(hw2);
  266.         
  267. /*  -h heap  */
  268. }
  269.  
  270.  
  271.  
  272. void AVL_SET_PGM_STACK() 
  273. {
  274.     AVL_WIN_PTR hw, hw2;
  275.     short h;
  276.     char msg[80];
  277.     hw2 = AVL_MAKE_WINDOW("",19,5,24,75,avl_wnd_bk_color,avl_wnd_color);
  278.     _outtext(" Specifies the size in bytes of the program stack size for the main\n");
  279.     _outtext(" task. The default is 4096. Argument values in the range 1..31 are\n");
  280.     _outtext(" multiplied by 1024 to obtain the stack size in bytes. The maximum\n");
  281.     _outtext(" value is 32767. ");
  282.     hw = AVL_MAKE_WINDOW(" Program Stack ",13,20,13+2
  283.                                           ,63,avl_wnd_bk_color,avl_wnd_color);
  284.     while ( 1 )   {
  285.         sprintf(msg,"%d", avl_pgm_stack);
  286.         if (AVL_PROMPT(1,3,msg,3)) break;
  287.         if (strlen(msg) > 0) {
  288.             h = atoi(msg);
  289.             if (h <= 0) AVL_ERROR("Invalid stack size."); 
  290.             else {
  291.                 avl_pgm_stack = h;
  292.                 break;
  293.                 }
  294.             }
  295.         }
  296.     AVL_DEL_WINDOW(hw);
  297.     AVL_DEL_WINDOW(hw2);
  298.         
  299. /*  -p pstack */
  300. }
  301.  
  302. void AVL_SET_PARAMETERS()
  303. {
  304.     AVL_BIND_SIZE c[7];
  305.     PROC_NAME rot[7] = {AVL_SET_MONITOR
  306.                        ,AVL_SET_HEAP_SIZE
  307.                        ,AVL_SET_PGM_STACK
  308.                        ,AVL_SET_TASK_STACK
  309.                        ,AVL_SET_SCHEDULER
  310.                        ,AVL_SET_TRACE
  311.                        ,NULL};
  312.     int i;
  313.     int save_unit;
  314.     int ch, cols = 16, rows = 6;
  315.     AVL_WIN_PTR hw, hw2;
  316.     strcpy(c[0].name,"Monitoring");
  317.     strcpy(c[1].name,"Heap Size");
  318.     strcpy(c[2].name,"Program Stack");
  319.     strcpy(c[3].name,"Task Stack");
  320.     strcpy(c[4].name,"Scheduller");
  321.     strcpy(c[5].name,"Trace");
  322.     save_unit = avl_cur_unit;
  323.     avl_cur_unit = avl_cur_par;
  324.     avl_size = rows;
  325.  
  326.     hw2 = AVL_MAKE_WINDOW("",15,55,15+9,55+24,avl_wnd_bk_color,avl_wnd_color);
  327.     _outtext(" Use the arrow keys to\n");
  328.     _outtext(" go over the  options.\n");
  329.     _outtext("\n");
  330.     _outtext(" Press  <enter>  to\n");
  331.     _outtext(" select an option or\n");
  332.     _outtext(" type the option's no.\n");
  333.     _outtext("\n");
  334.     _outtext(" Press ESC to  cancel.");
  335.     hw = AVL_MAKE_WINDOW(" Parameters ",3,avl_menu[6].c,3+rows+1,avl_menu[6].c+cols+5,avl_wnd_bk_color,avl_wnd_color);
  336.     while ( 1 )  {
  337.         AVL_SHOW_UNIT(c,cols);
  338.         ch = getch();
  339.         if ((ch >= '1' && ch <= '6') || (ch == 13)) {
  340.             if (ch != 13)
  341.                 avl_cur_unit += (ch - '0' - 1);
  342.             avl_cur_par = avl_cur_unit;
  343.             avl_cur_unit = save_unit;
  344.             rot[avl_cur_par]();
  345.             }
  346.         else {
  347.             if (ch == 0 || ch == 0xE0) {
  348.                 ch = getch();
  349.                 switch( ch ) {
  350.                        case 72 : /* Up */ 
  351.                            if (--avl_cur_unit < 0)  
  352.                             avl_cur_unit = avl_size - 1;
  353.                            break;
  354.                        case 80 : /* Down */ 
  355.                            if (++avl_cur_unit >= avl_size)
  356.                                avl_cur_unit = 0;
  357.                            break;
  358.                        default : putchar(7); break;
  359.                        }
  360.                 continue;
  361.                 }
  362.             if (ch == 27)  {
  363.                 AVL_DEL_WINDOW(hw);
  364.                 AVL_DEL_WINDOW(hw2);
  365.                 avl_cur_par = avl_cur_unit;
  366.                 avl_cur_unit = save_unit;
  367.                 return;
  368.                 }
  369.             putch(7);
  370.             continue;
  371.             }
  372.         }
  373. }
  374.  
  375.  
  376.